<template>
  <base-breadcrumb
    v-loading="loading"
    :breadcrumb="!isAudit"
  >
    <div class="about-master-container">
      <a-tabs
        v-if="baseChangeStatus"
        type="card"
        :active-key="activeKey"
        @change="tabChange"
      >
        <a-tab-pane
          key="1"
          tab="基本信息"
        >
          <change
            :base-form="form1"
            :state="state"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('5')"
          key="5"
          tab="用印申请"
        >
          <a-card>
            <title-name title="用印申请" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="申请单位">
                {{ form1.branchComName }}
              </a-descriptions-item>
              <a-descriptions-item label="相对方">
                {{ form1.otherParty }}
              </a-descriptions-item>
              <a-descriptions-item label="合同额（万元）">
                {{ form1.amount }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合同类型">
                {{ form5.contractTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="合同编号">
                {{ form5.contractCode }}
              </a-descriptions-item>
              <a-descriptions-item label="合同份数">
                {{ form5.contractQuantity }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="项目经理">
                {{ form5.pmEmployeeName }}
              </a-descriptions-item>
              <a-descriptions-item label="项目经理联系电话">
                {{ form5.pmEmployeePhone }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="特别说明">
                {{ form5.specialInstructions }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="本合同是否按规定流程经过评审通过">
                {{ ['否', '是'][form5.review] || '无' }}
              </a-descriptions-item>
              <a-descriptions-item label="本合同审核意见处理情况">
                {{ ['无审核意见', '已按审核意见采纳', '未采纳'][(form5.auditHandle || 0) - 1] || '无' }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="本合同审核意见处理情况">
                {{ form5.handleNote }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="经办责任人">
                {{ form5.agentName }}
              </a-descriptions-item>
              <a-descriptions-item label="经办责任人联系电话">
                {{ form5.agentEmployeePhone }}
              </a-descriptions-item>
              <a-descriptions-item label="申请日期">
                {{ form5.applyTime | dateFormat('d') }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <a-card>
            <title-name title="附件" />
            <u-table
              :is-show="false"
              :is-upload="false"
              :upload-arrys="form5.fileInfos"
            />
          </a-card>
        </a-tab-pane>
      </a-tabs>
      <a-tabs
        v-if="!baseChangeStatus"
        type="card"
        :active-key="activeKey"
        @change="tabChange"
      >
        <a-tab-pane
          key="1"
          tab="基本信息"
        >
          <a-card>
            <title-name title="基本信息" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="所属单位">
                <span :title="form1.branchComName"> {{ (form1.branchComName+'/'+form1.projectName)|ellipsis  }}</span>
              </a-descriptions-item>
              <!-- <a-descriptions-item label="所属分公司">
                <span :title="form1.branchComName"> {{ form1.branchComName|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="项目名称">
                <span :title="form1.projectName"> {{ form1.projectName|ellipsis  }}</span>
              </a-descriptions-item> -->
              <a-descriptions-item label="建设单位名称">
                <span :title="form1.otherParty"> {{ form1.otherParty|ellipsis  }}</span>
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="建设单位性质">
                {{ form1.buildTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="中标时间">
                {{ form1.bidDate }}
              </a-descriptions-item>
              <a-descriptions-item label="签约时间">
                {{ form1.signDate }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合同类型">
                {{ form1.contractTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="合同额（万元）">
                {{ form1.amount }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合同份数">
                {{ form1.contractNum }}
              </a-descriptions-item>
              <a-descriptions-item label="项目经理">
                {{ form1.pmEmployeeName }}
              </a-descriptions-item>
              <a-descriptions-item label="联系电话">
                {{ form1.pmEmployeePhone }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="是否有重大风险">
                {{ form1.majorRisk == 1 ? '是' : '否' }}
              </a-descriptions-item>
              <a-descriptions-item label="项目业态">
                {{ form1.projectFormatStr }}
              </a-descriptions-item>
              <a-descriptions-item label="项目类型">
                {{ form1.projectTypeStr }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="预付款金额（万元）">
                {{ form1.advanceAmount }}
              </a-descriptions-item>
              <a-descriptions-item label="付款方式">
                {{ form1.payTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="付款比例（%）">
                {{ form1.paymentProportion }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="结算条件">
                {{ form1.settleCnditionsStr }}
              </a-descriptions-item>
              <a-descriptions-item label="施工范围">
                {{ form1.scopeTypeStr }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="特别说明">
                {{ form1.specialInstructions }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="创建人">
                {{ form1.creatorName }}
              </a-descriptions-item>
              <a-descriptions-item label="创建时间">
                {{ form1.createTime }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <a-card v-if="!isAudit">
            <title-name title="分公司评审人员" />
            <a-descriptions>
              <a-descriptions-item label="市场部/基础设施部">
                {{ form1.bcMarkeDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="工程管理部">
                {{ form1.bcEngineeDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="财务资金部">
                {{ form1.bcFinanceDeptName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合约法务部">
                {{ form1.bcLegalDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="商务管理部">
                {{ form1.bcMinistryDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="科技部">
                {{ form1.bcTechnologyDeptName }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <a-card v-if="!isAudit">
            <title-name title="公司评审人员" />
            <a-descriptions>
              <a-descriptions-item label="市场部/基础设施部">
                {{ form1.coMarkeDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="工程管理部">
                {{ form1.coEngineeDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="财务资金部">
                {{ form1.coFinanceDeptName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合约法务部">
                {{ form1.coLegalDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="商务管理部">
                {{ form1.coMinistryDeptName }}
              </a-descriptions-item>
              <a-descriptions-item label="科技部">
                {{ form1.coTechnologyDeptName }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <attachment
            :attachment="form1.fileInfos"
            :disabled="false"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('2')"
          key="2"
          tab="合同评审（分公司）"
        >
          <ContractReviewBranch
            :state="state"
            type="Branch"
            :base-form="form1"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('2')"
          key="10"
          tab="合同评审（公司）"
        >
          <ContractReviewBranch
            :state="state"
            type="company"
            :base-form="form1"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('3')"
          key="3"
          tab="合同评审汇总（公司）"
        >
          <a-card>
            <title-name title="合同评审汇总（公司）" />
            <a-descriptions>
              <a-descriptions-item label="实施单位">
                中国建筑第八工程局有限公司西南分公司
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="项目名称">
                <span :title="form1.projectName"> {{ form1.projectName|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="建设单位">
                <span :title="form1.otherParty"> {{ form1.otherParty|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="合同额（万元）">
                {{ form1.amount }}
              </a-descriptions-item>
              <a-descriptions-item
                label="总建筑面积（㎡）"
                v-if="!form1.linearIs"
              >
                {{ form3.totalArea }}
              </a-descriptions-item>
              <a-descriptions-item
                label="其中地下建筑面积（㎡）"
                v-if="!form1.linearIs"
              >
                {{ form3.undergroundArea }}
              </a-descriptions-item>
              <a-descriptions-item
                label="结构形式"
                v-if="!form1.linearIs"
              >
                {{ form3.structureStyle }}
              </a-descriptions-item>
              <a-descriptions-item
                label="层数（地下+地上）"
                v-if="!form1.linearIs"
              >
                {{ form3.floor }}
              </a-descriptions-item>
              <a-descriptions-item
                label="合同工程里程"
                v-if="form1.linearIs"
              >
                {{ form3.totalKm }}
              </a-descriptions-item>
              <a-descriptions-item label="质量等级">
                <span :title="form3.qualityLevel"> {{ form3.qualityLevel|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="工期（月）">
                {{ form3.constructionPeriod }}
              </a-descriptions-item>
              <a-descriptions-item label="预期利润率(%)（不含税）">
                {{ form3.predictProfitRate }}
              </a-descriptions-item>
              <a-descriptions-item label="承包方式">
                <span :title="form3.contractMode"> {{ form3.contractMode|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="承包范围">
                {{ form3.scope }}
              </a-descriptions-item>
              <a-descriptions-item label="合同类型">
                {{ form3.comReviewTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="合同等级">
                {{ form3.comReviewLevelStr }}
              </a-descriptions-item>
            </a-descriptions>
            <div class="project-site">
              <span>工程地点：</span>
              <span :title="form3.address">{{ form3.address | ellipsis}}</span>
            </div>
            <a-row
              v-for="item of form3.options"
              :key="item.id"
              class="mb20"
            >
              <a-col span="4">
                {{ item.name }}
              </a-col>
              <a-col span="14">
                <a-row>
                  <a-col
                    v-for="child of item.children"
                    :key="child.id"
                    span="20"
                  >
                    <a-checkbox
                      v-model="child.hasSelected"
                      disabled
                      :value="child.id"
                    >
                      {{ child.name }}
                    </a-checkbox>
                  </a-col>
                </a-row>
              </a-col>
            </a-row>
          </a-card>
          <attachment
            :attachment="form3.fileInfos"
            :disabled="state !== 3"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('4')"
          key="4"
          tab="授权申请"
        >
          <a-card>
            <title-name title="授权申请" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="所属单位">
                <span :title="form1.projectName"> {{ (form1.branchComName+'/'+form1.projectName)|ellipsis}}</span>
              </a-descriptions-item>

              <!-- <a-descriptions-item label="所属分公司">
                <span :title="form1.branchComName"> {{ form1.branchComName|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="项目名称">
                <span :title="form1.projectName"> {{ form1.projectName|ellipsis  }}</span>
              </a-descriptions-item> -->
              <a-descriptions-item label="业主名称">
                <span :title="form1.otherParty"> {{ form1.otherParty|ellipsis  }}</span>
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合同额（万元）">
                {{ form1.amount }}
              </a-descriptions-item>
              <a-descriptions-item :label="form1.linearIs?'建筑规模（km）':'建筑规模（m²）'">
                {{ form4.buildingScale }}
              </a-descriptions-item>
              <a-descriptions-item label="工程类别">
                {{ form4.projectType }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="开竣工时间">
                {{ form4.startTime | dateFormat('D') }} ~
                {{ form4.endTime | dateFormat('D') }}
              </a-descriptions-item>
              <a-descriptions-item label="受托人姓名">
                <span :title="form4.trusteeName"> {{ form4.trusteeName|ellipsis  }}</span>
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="身份证">
                {{ form4.trusteeIdCard | idCard }}
              </a-descriptions-item>
              <a-descriptions-item label="单位及部门">
                <span :title="form4.trusteeOrgName"> {{ form4.trusteeOrgName|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="职务">
                {{ form4.trusteePostName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="授权书有效期">
                {{ form4.authorizationTimeStartTime | dateFormat('D') }} ~
                {{ form4.authorizationTimeEndTime | dateFormat('D') }}
              </a-descriptions-item>
              <a-descriptions-item label="授权书格式">
                {{ form4.letterOfAuthorizationStr }}
              </a-descriptions-item>
              <a-descriptions-item label="是否公证">
                {{ form4.notarization === '1' ? '是' : '否' }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="授权权限">
                {{ form4.authorization }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="办理份数（中）">
                {{ form4.chinese }}
              </a-descriptions-item>
              <a-descriptions-item label="办理份数（英）">
                {{ form4.english }}
              </a-descriptions-item>
              <a-descriptions-item label="办理份数（其他）">
                {{ form4.others }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="完成时间">
                {{ form4.completeTime | dateFormat('D') }}
              </a-descriptions-item>
              <a-descriptions-item label="申请人">
                {{ form4.applicantName }}
              </a-descriptions-item>
              <a-descriptions-item label="申请时间">
                {{ form4.applyTime | dateFormat('D') }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <a-card>
            <title-name title="附件" />
            <u-table
              :is-show="false"
              :is-upload="false"
              :upload-arrys="form4.fileInfos"
            />
          </a-card>
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('5')"
          key="5"
          tab="用印申请"
        >
          <a-card>
            <title-name title="用印申请" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="申请单位">
                <span :title="form1.branchComName"> {{ form1.branchComName|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="相对方">
                <span :title="form1.otherParty"> {{ form1.otherParty|ellipsis  }}</span>
              </a-descriptions-item>
              <a-descriptions-item label="合同额（万元）">
                {{ form1.amount }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="合同类型">
                {{ form5.contractTypeStr }}
              </a-descriptions-item>
              <a-descriptions-item label="合同编号">
                {{ form5.contractCode }}
              </a-descriptions-item>
              <a-descriptions-item label="合同份数">
                {{ form5.contractQuantity }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="项目经理">
                {{ form5.pmEmployeeName }}
              </a-descriptions-item>
              <a-descriptions-item label="项目经理联系电话">
                {{ form5.pmEmployeePhone }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="特别说明">
                {{ form5.specialInstructions }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="本合同是否按规定流程经过评审通过">
                {{ ['否', '是'][form5.review] || '无' }}
              </a-descriptions-item>
              <a-descriptions-item label="本合同审核意见处理情况">
                {{ ['无审核意见', '已按审核意见采纳', '未采纳'][(form5.auditHandle || 0) - 1] || '无' }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="本合同审核意见处理情况">
                {{ form5.handleNote }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="经办责任人">
                {{ form5.agentName }}
              </a-descriptions-item>
              <a-descriptions-item label="经办责任人联系电话">
                {{ form5.agentEmployeePhone }}
              </a-descriptions-item>
              <a-descriptions-item label="申请日期">
                {{ form5.applyTime | dateFormat('d') }}
              </a-descriptions-item>
            </a-descriptions>
          </a-card>
          <a-card>
            <title-name title="附件" />
            <u-table
              :is-show="false"
              :is-upload="false"
              :upload-arrys="form5.fileInfos"
            />
          </a-card>
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('6')"
          key="6"
          tab="成本分析表"
        >
          <CostAnalysisTable
            :id="baseId"
            :state="state"
            :base-form="form1"
          />
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('7')"
          key="7"
          tab="资金策划表"
        >
          <MoneyPlanning
            :base-form="form7"
            :disabled="true"
          />
          <!-- <a-card>
            <title-name title="资金策划表" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="填报人">
                {{ form7.fillByName }}
              </a-descriptions-item>
              <a-descriptions-item label="填报日期">
                {{ form7.fillDate | dateFormat('d') }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="资金策划表附件">
                <a
                  v-if="form7.fileInfo.fileId"
                  :href="
                    '/api/ycloud-file-center/oper/download?access_token=' +
                      token +
                      '&fileId=' +
                      form7.fileInfo.fileId
                  "
                  target="_parent"
                >
                  {{ form7.fileInfo.fileName }}
                </a>
              </a-descriptions-item>
            </a-descriptions>
          </a-card> -->
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('8')"
          key="8"
          tab="重大风险化解措施"
        >
          <LargeRisk
            :base-form="form8"
            :disabled="true"
          />
          <!-- <a-card>
            <title-name title="重大风险化解措施" />
            <a-descriptions>
              <a-descriptions-item label="合同名称">
                {{ form1.contractName }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="填报人">
                {{ form8.fillByName }}
              </a-descriptions-item>
              <a-descriptions-item label="填报日期">
                {{ form8.fillDate | dateFormat('d') }}
              </a-descriptions-item>
            </a-descriptions>
            <a-descriptions>
              <a-descriptions-item label="重大风险化解措施附件">
                <a
                  v-if="form8.fileInfo.fileId"
                  :href="
                    '/api/ycloud-file-center/oper/download?access_token=' +
                      token +
                      '&fileId=' +
                      form8.fileInfo.fileId
                  "
                  target="_parent"
                >
                  {{ form8.fileInfo.fileName }}
                </a>
              </a-descriptions-item>
            </a-descriptions>
          </a-card> -->
        </a-tab-pane>
        <a-tab-pane
          v-if="isShow('9')"
          key="9"
          tab="风险复核"
        >
          <!--<a-card>-->
          <!--<title-name title="风险复核" />-->
          <DangerReview :base-form="form1" />
          <!--</a-card>-->
        </a-tab-pane>
        <!-- <a-tab-pane
          key="10"
          tab="相关附件"
        >
          <a-card>
            <title-name title="相关附件" />
            <u-table
              :is-show="false"
              business-code="LCM08"
              :list-url="findFileList"
              :upload-list="addFile"
              :delete-url="deleteFile"
              :business-id="form1.baseId"
            />
          </a-card>
        </a-tab-pane> -->
      </a-tabs>
      <div
        class="operation page-btn-right-top"
        style="text-align: right; margin-right: 20px"
      >
        <template v-if="!isHistory">
          <BasePrintButton
            v-if="activeKey === '7'"
            class="mr10p"
            style="display: inline-block"
            :use-component="componentInstance"
            :component-query="{businessId: form7.businessId }"
          />
          <BasePrintButton
            v-if="
              activeKey === '2' ||
                activeKey === '3' ||
                activeKey === '4' ||
                activeKey === '5' ||
                activeKey === '6' ||
                activeKey === '8' ||
                activeKey === '9' ||
                activeKey === '10' ||
                baseChangeStatus
            "
            :before-print-fn="beforePrintFn"
            class="mr10p"
            style="display: inline-block"
          />
        </template>
        <a-button
          v-checkVisibleInDetail
          @click="$close()"
        >
          关闭
        </a-button>
      </div>
    </div>
  </base-breadcrumb>
</template>
<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import ContractReviewBranch from './components/ContractReviewBranch' //tab2  合同评审（分公司）
import AuthApply from './components/AuthApply'
import UsePrintApply from './components/UsePrintApply'
import CostAnalysisTable from './components/CostAnalysisTable'
import ContractReview from './components/ContractReview'
import attachment from './components/attachment'
import MoneyPlanning from './components/MoneyPlanning'
import LargeRisk from './components/LargeRisk'
import DangerReview from './components/DangerReview'
import change from './components/change'
import FundPlanning from '@/printTemplates/FundPlanning.vue'

//api接口
import totalPackageContractApi from '@/api/legal/branchContract/totalPackageContract'
import Vue from 'vue'

export default {
  name: 'a' + Date.now(),
  components: {
    ContractReviewBranch,
    CostAnalysisTable,
    attachment,
    MoneyPlanning,
    LargeRisk,
    DangerReview,
    change
  },
  props: {
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    isAudit: {
      handler(val, oldVal) {
        if (val) {
          this.state = 3
        }
      },
      immediate: true
    }
  },
  data() {
    return {
      componentInstance: FundPlanning, // 资金策划表的打印模板
      beforePrintFnContractReviewBranch: async () => {
        let taskDefKey = this.$route.query.taskDefKey
        let code = []
        switch (taskDefKey) {
          case 'legal_general_branchcom_basic':
            code = [1001]
            break
          case 'legal_general_branchcom_project':
            code = [1002]
            break
          case 'legal_general_branchcom_finance':
            code = [1003]
            break
          case 'legal_general_branchcom_legal':
            code = [1004]
            break
          case 'legal_general_branchcom_business':
            code = [1005]
            break
          case 'legal_general_branchcom_science':
            code = [1006]
            break
          case 'legal_general_company_new':
            code = [1006]
            break
          default:
            code = [1001, 1002, 1003, 1004, 1005, 1006]
            break
        }
        let res = await totalPackageContractApi.comAuditInfoPrint({
          modelCodes: code,
          pageNo: 1,
          pageSize: 10000,
          baseId: this.baseId || this.$route.query.businessId,
          edit: false
        })
        if (res.code === this.SUCCESS_CODE) {
          return res.data.content
        }
      },
      beforePrintFn: async () => {
        let res
        let taskDefKey = this.$route.query.taskDefKey
        let code = []
        switch (this.activeKey) {
          case '2':
            switch (taskDefKey) {
              case 'legal_general_branchcom_basic':
                code = [1001]
                break
              case 'legal_general_branchcom_project':
                code = [1002]
                break
              case 'legal_general_branchcom_finance':
                code = [1003]
                break
              case 'legal_general_branchcom_legal':
                code = [1004]
                break
              case 'legal_general_branchcom_business':
                code = [1005]
                break
              case 'legal_general_branchcom_science':
                code = [1006]
                break
              default:
                code = [1001, 1002, 1003, 1004, 1005, 1006]
                break
            }
            res = await totalPackageContractApi.branchComAuditInfoPrint({
              modelCodes: code,
              pageNo: 1,
              pageSize: 10000,
              baseId: this.baseId || this.$route.query.businessId,
              edit: false
            })
            break
          case '10':
            switch (taskDefKey) {
              case 'legal_general_com_basic':
                code = [1001]
                break
              case 'legal_general_com_project':
                code = [1002]
                break
              case 'legal_general_com_legal_adviser':
                code = [1003]
                break
              case 'legal_general_com_business':
                code = [1004]
                break
              case 'legal_general_com_finance':
                code = [1005]
                break
              case 'legal_general_com_legal':
                code = [1006]
                break
              default:
                code = [1001, 1002, 1003, 1004, 1005, 1006]
                break
            }
            res = await totalPackageContractApi.comAuditInfoPrint({
              modelCodes: code,
              pageNo: 1,
              pageSize: 10000,
              baseId: this.baseId || this.$route.query.businessId,
              edit: false
            })
            break
          case '3':
            res = await totalPackageContractApi.comReviwPrint(
              {},
              {
                baseId: this.baseId,
                businessId: this.businessId,
                edit: false
              }
            )
            break
          case '4':
            res = await totalPackageContractApi.applyForAuthorityPrint(
              {},
              {
                baseId: this.baseId,
                businessId: this.businessId,
                edit: false
              }
            )
            break
          case '5':
            res = await totalPackageContractApi.sealPrint(
              {},
              {
                baseId: this.baseId,
                businessId: this.businessId
              }
            )
            break
          case '6':
            res = await totalPackageContractApi.analysisPrint(
              {},
              {
                baseId: this.baseId,
                businessId: this.businessId
              }
            )
            break
          case '8':
            res = await totalPackageContractApi.risksPrint(
              {},
              {
                businessId: this.form8.businessId
              }
            )
            break
          case '9':
            res = await totalPackageContractApi.DangerReviewPrint(
              {},
              {
                id: this.baseId
                // id: this.businessId
              }
            )
            break
        }
        // 合同变更打印接口
        if (this.baseChangeStatus) {
          res = await totalPackageContractApi.contractChange(
            {},
            {
              id: this.baseId
              // id: this.businessId
            }
          )
        }
        if (res.code === this.SUCCESS_CODE) {
          return res.data.content
        }
      },
      loading: false,
      state: Number(this.$route.query.state),
      baseChangeStatus: this.$route.query.baseChangeStatus == '1',
      activeKey: '1',
      isHistory: false,
      isApproval: false,
      baseId: this.$route.query.id,
      form1: {
        branchComName:'',
        projectName:''

      },
      form2: {},
      form3: {},
      form4: {},
      form5: {},
      form6: {},
      form7: {},
      form8: {},
      addFile: totalPackageContractApi.addFile(),
      deleteFile: totalPackageContractApi.deleteFile(),
      findFileList: totalPackageContractApi.findFileList(),
      token: '',
      businessId: this.$route.query.businessId,
      activeTab: null
    }
  },
  created: async function () {
    this.token = Vue.getAcloudProvider().getAccessToken()
    if (this.$route.query.businessType) {
      this.activeKey = this.activeTab = this.$route.query.activeKey || this.$route.query.businessType.substr(3, 1)
      if (this.activeKey === '2' || this.activeKey === '1') {
        this.activeKey = '1'
        // this.businessId = ''
      } else {
        this.baseId = ''
      }
      console.log(this.$route.query.businessType)
      this.isApproval = true
      let baseId = (this.baseId = await this.tabChange(this.activeKey))
      await this.getBaseInfo(baseId)
    } else {
      await this.getBaseInfo(this.baseId)
    }
    if (this.$route.query.activeKey) {
      this.activeTab = this.activeKey = this.$route.query.activeKey
      // this.isHistory = true
      await this.tabChange(this.activeKey)
    }
  },
  mounted() {
    this.$bus.$once('getBaseInfo', this.getBaseInfo)
  },
  methods: {
    isShow(key) {
      if (this.isHistory || this.isApproval) {
        return key === this.activeTab
      }
      return true
    },
    async getBaseInfo(baseId) {
      let params = { baseId }
      //如果是基本信息变更的审批详情，那么key要用businessId
      if (this.$route.query.businessType === '1111' || this.$route.query.activeKey === '1') {
        params = { businessId: this.businessId }
      }
      let requestFun = totalPackageContractApi.findListByMainId
      if (this.$route.query.activeKey === '1') {
        requestFun = totalPackageContractApi.findGeneralContractHistoryByBusinessId
      }

      if (!baseId) return
      this.loading = true
      let res = await requestFun({}, params)
      if (res.code === 200) {
        this.form1 = res.data
      }
      this.loading = false
    },
    async tabChange(key) {
      this.activeKey = key
      let res
      this.loading = true
      if (this.isHistory) {
        switch (key) {
          case '1':
            res = await totalPackageContractApi.findGeneralContractHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form1 = res.data
            }
            break
          case '3':
            res = await totalPackageContractApi.findComReviewHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form3 = res.data
            }
            break
          case '4':
            res = await totalPackageContractApi.findApplyForAuthorityHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form4 = res.data
            }
            break
          case '5':
            res = await totalPackageContractApi.findApplyForSealHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form5 = res.data
            }
            break
          case '6':
            res = await totalPackageContractApi.findGeneralContractCostAnalysisHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form6 = res.data
            }
            break
          case '7':
            res = await totalPackageContractApi.findProjectFundPlanTableHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form7 = res.data
            }
            break
          case '8':
            res = await totalPackageContractApi.findGeneralContractMajorRisksHistoryByBusinessId({}, { businessId: this.businessId })
            if (res.code === 200) {
              this.form8 = res.data
            }
            break
        }
      } else {
        switch (key) {
          case '1':
            if (!this.form1.baseId) {
              await this.getBaseInfo(this.baseId)
            }
            break
          case '2':
            // res = await totalPackageContractApi.findBranchComAuditInfoByBaseId({}, { baseId: this.baseId })
            // if (res.code === 200) {
            //     this.form2 = res.data
            // }
            break
          case '3':
            if (!this.form3.baseId) {
              res = await totalPackageContractApi.findComReviewByBaseId(
                {},
                {
                  baseId: this.baseId,
                  businessId: this.businessId
                }
              )
              if (res.code === 200) {
                this.form3 = res.data
              }
            }
            break
          case '4':
            if (!this.form4.baseId) {
              res = await totalPackageContractApi.findApplyForAuthorityByBaseId(
                {},
                {
                  baseId: this.baseId,
                  businessId: this.businessId
                }
              )
              if (res.code === 200) {
                this.form4 = res.data
              }
            }
            break
          case '5':
            if (!this.form5.baseId) {
              res = await totalPackageContractApi.findApplyForSealByBaseId(
                {},
                {
                  baseId: this.baseId,
                  businessId: this.businessId
                }
              )
              if (res.code === 200) {
                this.form5 = res.data
              }
            }
            break
          case '6':
            // res = await totalPackageContractApi.findGeneralContractCostAnalysisByBaseId({}, { baseId: this.baseId,businessId:this.businessId })
            // if (res.code === 200) {
            //     this.form6 = res.data
            // }
            break
          case '7':
            if (!this.form7.baseId) {
              res = await totalPackageContractApi.findProjectFundPlanTableByBaseId(
                {},
                {
                  baseId: this.baseId,
                  businessId: this.businessId
                }
              )
              if (res.code === 200) {
                this.form7 = res.data
              }
            }
            break
          case '8':
            if (!this.form8.baseId) {
              res = await totalPackageContractApi.findMajorRisksByBaseId(
                {},
                {
                  baseId: this.baseId,
                  businessId: this.businessId
                }
              )
              if (res.code === 200) {
                this.form8 = res.data
                if (!res.data.projectName) {
                  this.form8.projectName = this.form1.projectName
                }
              }
            }
            break
        }
      }
      this.loading = false
      return res && res.data.baseId
    }
  }
}
</script>
<style lang="less">
#components-layout-demo-custom-trigger .ant-tabs-bar.ant-tabs-top-bar.ant-tabs-card-bar {
  margin: 0 !important;
}

.about-master-container {
  padding: 0 15px;

  .ant-card-body {
    padding: 20px;
  }
}

.ant-checkbox-disabled + span {
  color: black;
}

.ant-checkbox-disabled.ant-checkbox-checked .ant-checkbox-inner::after {
  border-color: black;
}

.ant-descriptions-item {
  // white-space: nowrap;
}

.ant-descriptions-item > span {
    display: contents;
}
.project-site {
  display: flex;
  margin-bottom: 20px;
  span:first-of-type {
    color: rgba(0, 0, 0, 0.85);
    width: 127px;
  }
}
</style>
